package behavior.strategy.versionThree;

import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * @author huhaiqiang
 * @version V1.0
 * @description 付款上下文
 * @date 2018/12/03 17:46
 */
@Slf4j
public class CashContext {

    private CashSuperStrategy cashSuperStrategy;

    public CashContext(int type) {
        switch (type) {
            case 1:
                cashSuperStrategy = new ConcreteStrategyOne();
                log.info("当前没有活动");
                break;
            case 2:
                cashSuperStrategy = new ConcreteStrategyTwo(new BigDecimal("300"),new BigDecimal("100"));
                log.info("当前活动为：满300减100");
                break;
            case 3:
                cashSuperStrategy = new ConcreteStrategyThree("0.8");
                log.info("当前活动为：打八折");
                break;
            default:
        }
    }

    public BigDecimal getResult(BigDecimal money) {
        return cashSuperStrategy.acceptCash(money);
    }


}
